package controlLayer;

import modelLayer.ClassRoomCon;
import controlLayer.ClassRoomCtr;
import modelLayer.SubjectCon;
import modelLayer.Subject;
import modelLayer.ClassCon;
import modelLayer.TeacherCon;
import modelLayer.Teacher;
import modelLayer.Class;

public class DemoData {
	
	public DemoData(){
		
	}
		
	public void loadDemoData(){
		
		this.createRoom();
		this.createSubject();
		this.createTeacher();
		this.createClass();
		this.addTeachersToSubjects();
		
	}
	
	public void createRoom(){
		
		ClassRoomCon classRoomCon = ClassRoomCon.getInstance();
		ClassRoomCtr crc = new ClassRoomCtr();
		
		classRoomCon.addRoom(crc.createClassRoom("Bio"));
		classRoomCon.addRoom(crc.createClassRoom("L01"));
		classRoomCon.addRoom(crc.createClassRoom("L02"));
		classRoomCon.addRoom(crc.createClassRoom("L03"));
		classRoomCon.addRoom(crc.createClassRoom("Gym"));
		
		for (int i = 0; i < classRoomCon.getAll().size(); i++){
			System.out.println(classRoomCon.getAll().get(i).toString() + " Successfully created!");
		}
	}
	
	public void createSubject(){
		
		SubjectCon subjectCon = SubjectCon.getInstance();
		
		Subject s1 = new Subject("History");
		Subject s2 = new Subject("Mathematics");
		Subject s3 = new Subject("English");
		Subject s4 = new Subject("Danish");
		Subject s5 = new Subject("Geography");
		
		s1.setID(1);
		s2.setID(2);
		s3.setID(3);
		s4.setID(4);
		s5.setID(5);
		
		subjectCon.addSubject(s1);
		subjectCon.addSubject(s2);
		subjectCon.addSubject(s3);
		subjectCon.addSubject(s4);
		subjectCon.addSubject(s5);
		
		System.out.println(s1.toString() + " - Successfully created!\n" +
	    					s2.toString() + " - Successfully created!\n" +
							s3.toString() + " - Successfully created!\n" +
							s4.toString() + " - Successfully created!\n" +
							s5.toString() + " - Successfully created!\n");
	}
	
	public void createTeacher() {
		
		TeacherCon tCon = TeacherCon.getInstance();
	
		Teacher t1 = new Teacher("Frederik");
		Teacher t2 = new Teacher("Susanne");
		Teacher t3 = new Teacher("Michael");
		Teacher t4 = new Teacher("Rebecca");
		Teacher t5 = new Teacher("Lars");
		
		t1.setID(1);
		t2.setID(2);
		t3.setID(3);
		t4.setID(4);
		t5.setID(5);
		
		tCon.addTeacher(t1);
		tCon.addTeacher(t2);
		tCon.addTeacher(t3);
		tCon.addTeacher(t4);
		tCon.addTeacher(t5);
		
		System.out.println(t1.toString() + " was succesfully created.");
		System.out.println(t2.toString() + " was succesfully created.");
		System.out.println(t3.toString() + " was succesfully created.");
		System.out.println(t4.toString() + " was succesfully created.");
		System.out.println(t5.toString() + " was succesfully created.");
		
	}
	
	public void createClass() {
		
		ClassCon cCon = ClassCon.getInstance();
		
		Class c1 = new Class("1. Klasse", "N/A");
		Class c2 = new Class("2. Klasse", "N/A");
		
		cCon.addClass(c1);
		cCon.addClass(c2);
		
		System.out.println(c1.toString() + " was succesfully created.");
		System.out.println(c2.toString() + " was succesfully created.");

		
	}
	
	public void addTeachersToSubjects() {
		
		SubjectCon subjectCon = SubjectCon.getInstance();
		TeacherCon tCon = TeacherCon.getInstance();
		
		for (int i = 0; i < tCon.getTeachers().size() && i < subjectCon.getSubjects().size(); i++) {
			subjectCon.getSubjects().get(i).setTeacher(tCon.getTeachers().get(i));
			System.out.println(subjectCon.getSubjects().get(i).toString() + " " + subjectCon.getSubjects().get(i).getTeacher().getName());
		}
		
	}
	
}

